<template>
  <div class="section-wrap hiddenlc" style="height:100%;margin-top: 40px;">
      <!-- 头部 -->
      <div class="headerBox">
        <div class="header">
          <x-icon type="ios-arrow-left" size="" class="icon-white" @click="goBack"></x-icon>
          问题总数量
        </div>
      </div>
      <vue-better-scroll
      class="wrapper"
      ref="scrollqq"
      :scrollbar="scrollbarObj"
      :pullDownRefresh="pullDownRefreshObj"
      :pullUpLoad="pullUpLoadObj"
      :startY='parseInt(startY)'
      @pullingUp="onPullingUp"
    > 
      <div class="form-section">
        <div class="info_div2">
          <div class="form-item">
            <div><span>问题总数量: {{totalCount}}</span></div>
          </div>
        </div>
        <div class="project_div">
          <ul class="project_list">
            <li v-for='(item,index) in accpentlist' :key="index" @click="$router.push({path: `/hiddeDetails?id=${item.id}`})">
              <div class="lf">
                <div>
                  <span style="font-size: 15px">{{item.hiddenDangerNum}}</span><br>
                  <span class="content" style="margin-top: 5px;">{{item.hiddenDangeDescription}}</span>
                </div>
                <div>
                  <span class="status" :class="{'big': item.hiddenDangerLevel.includes('重大')}">【{{item.hiddenDangerLevel}}】</span>
                  <span style="font-size: 12px;color: #ffb400" v-if="item.status=='0'">待提交</span>
                  <span style="font-size: 12px;color: #ffb400" v-if="item.status=='1'">待整改</span>
                  <span style="font-size: 12px;color: #ffb400" v-if="item.status=='2'">待验收</span>
                  <span style="font-size: 12px;color: #999999" v-if="item.status=='3'">已关闭</span>
                </div>
              </div>
              <div class="rf">
                <img v-if="item.projectImgList && item.projectImgList.length!=0" :src="item.projectImgList[0].url" style="width: 100px;height: 72px" alt="">
                <img v-if="!item.projectImgList || item.projectImgList.length==0" src="../../../static/images/hidden/pic.jpg" style="width: 100px;height: 72px" alt="">
              </div>
            </li>
          </ul>
        </div>
      </div>
    </vue-better-scroll>
  </div>

</template>
<script>
  import selectDepart from "@commonComponents/selectDepart/selectDepart";
  import formatDate from "../../utils/formatDate";
  import VueBetterScroll from "vue2-better-scroll"
  import {
    XHeader,
    Tabbar,
    TabbarItem,
    Group,
    Cell,
    TransferDom
  } from "vux";

  export default {
    directives: {
      TransferDom
    },
    data() {
      return {
        /*下拉刷新*/
        resultlist: [],
        scrollbarObj: {fade: true},
        pullDownRefreshObj: false,
        pullUpLoadObj: {
          threshold: 0,
          txt: {
            more: "加载更多",
            noMore: "没有更多数据了"
          }
        },
        startY: 20,
        scrollToX: 0,
        scrollToY: 0,
        scrollToTime: 700,
        url: "/api/services/app/Assessment/GetPageList",
        isDisabled: true, // 是否禁止输入
        totalCount: 0, //量化考试
        accpentlist: [],
        classValue: false,
        data: [],
        params: {
          isHomePage: '1',
          skipCount: 0,
          maxResultCount: 10
        },
        startDate: '',
        endDate: ''
      };
    },
    components: {
      selectDepart,
      VueBetterScroll
    },
    created() {
      this.getData();
      this.initDate();
    },
    mounted(){
        let that = this;
        this.$bridge.registerHandler("setToken", function(data) {
                         that.$store.state.Authorization =
          "Bearer " + data;
            //这里data ioS返回的是token值(字符串)
            that.getData();
        });

        this.connectWebViewJavascriptBridge(function(bridge) {
            bridge.init(function(message, responseCallback) {});

            bridge.registerHandler("setToken", function(data) {
                             that.$store.state.Authorization =
          "Bearer " + data;
            that.getData();
                  //这里data android返回的是token值(字符串)

            });
        });
    },
    methods: {
      connectWebViewJavascriptBridge(callback) {
            if (window.WebViewJavascriptBridge) {
                callback(WebViewJavascriptBridge);
            } else {
                document.addEventListener(
                "WebViewJavascriptBridgeReady",
                function() {
                    callback(WebViewJavascriptBridge);
                },
                false
                );
            }
        },
      getData() {
        this.$axiosAjax.getHiddenPageList(this.params).then(res => {
          if (res.data.success == true) {
            this.totalCount = res.data.result.totalCount;
            let relist = res.data.result.items;
            if (this.params.skipCount==0) {
              this.accpentlist = []
            }
            this.accpentlist = this.accpentlist.concat(relist);
            let totalAllCount = res.data.result.totalCount;
            let resultCount = this.accpentlist.length;
            if (parseInt(resultCount) < parseInt(totalAllCount)) {
              this.$refs['scrollqq'].forceUpdate(true);
            } else {
              this.$refs['scrollqq'].forceUpdate(false);
            }
          }
        });
      },
      // 初始化查询时间数据
      initDate() {
        // 设置默认查询结束时间
        this.endDate = formatDate();
        // 设置默认查询开始时间
        let dateArr = formatDate().split("-");
        this.startDate = dateArr[0] + "-" + dateArr[1] + "-" + "01";
      },
      goBack() {
        this.$bridge.callHandler({
          type: 'closePage',
          data: {}
        });
      },
      onPullingUp() {
        let limitcount = this.accpentlist.length;
        this.params.skipCount = limitcount;
        this.getData();
      }
    }
  };
</script>
<style lang="less" scoped>
  .search-btn {
    width: 200px;
    line-height: 36px;
    border-radius: 20px;
    margin: 23px auto;
    color: #fff;
    background: #469b7a;
    text-align: center;
    font-size:16px;
    letter-spacing: 4px;
  }

  .content {
    display: block;
    font-size: 13px;
    margin-top: 5px;
    padding-top: 5px;
    color: #666666;
    width: 230px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .status{
    font-size: 12px;color: #ff7333
  }
  .big{
    color: #ff0000
  }
  .classifyOneName {
    font-size: 12px;
    color: #666;
  }

  .lf {
    text-align: left;
    height: 100%;
    padding: 10px 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    .status {
      display: inline-block;
      min-width: 80px;
      margin-left: -4px;
    }
  }

  .rf {
    height: 100%;
    padding: 10px;
    img{
      display: block;
      height: 100% !important;
      padding-top: 0 !important;
    }
  }

  .form-item {
    .input_div {
      .vux-x-icon {
        fill: #999;
        float: right;
        margin-top: 18px;
      }

    }
    .vux-cell-box:not(:first-child):before {
      border: none !important;
    }
    .vue-cell-box {
      .weui-cell {
        padding-right: 0 !important;
        border: 0 !important;
      }
    }
  }

  .project_div {
    .project_list {
      box-sizing: border-box;
      padding-left: 10px;
      li {
        border-bottom: 1px solid #efeff4;
        height: 105px;
        position: relative;
        box-sizing: border-box;
        display: flex;
        justify-content: space-between;
        align-items: center;
        span{
          padding-left: 10px;
        }
        h4 {
          width: calc(100% - 50px);
          text-overflow: ellipsis;
          white-space: nowrap;
          overflow: hidden;
          font-size: 16px;
          margin-bottom: 8px;
          font-weight: bold;
        }


        .project_status {
          margin-top: 14px;
          strong {
            font-size: 12px;
          }

          strong.project_status1 {
            color: #ff7333;
          }

          strong.project_status2 {
            color: #469b7a;
          }

        }

        .vux-x-icon {
          fill: #999;
          right: 20px;
          top: 50%;
          margin-top: -11px;
          position: absolute;
        }

      }
    }
  }

  .add_btn {
    position: fixed;
    height: 62px;
    width: 62px;
    right: 30px;
    bottom: 35px;
  }
</style>

<style lang="less">
.hiddenlc .vux-cell-box .weui-cell {
  padding-right: 0 !important;
  border: 0 !important;
}
.hiddenlc .vux-cell-box:not(:first-child):before {
  border: none !important;
}
</style>
